const http=require("http")

const fs=require("fs")

const path=require("path")

const url=require("url")

// 创建服务
http.createServer((req,res)=>{
    let {pathname}=url.parse(req.url,true)
    pathname=pathname=="/"?"./index.html":pathname;
    // 判断是否有后缀
    if(path.extname(pathname)&&path.extname(pathname)!=="ico"){
        res.end(fs.readFileSync(path.join("./public",pathname),"utf-8"))
    }else if(pathname==="/login"){
        //....
    }
}).listen(9000,()=>{
    console.log("service is running at http://localhost:9000");
})